package com.sls.web.manager.action.ekhui;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sls.web.manager.action.SuperAction;
import com.sls.web.manager.common.Constants;
import com.sls.web.manager.common.DateUtil;
import com.sls.web.manager.game.client.DepositClient;
import com.sls.web.manager.game.client.PaymentClient;
import com.sls.web.manager.game.pojo.ekhui.Deposit;
import com.sls.web.manager.game.pojo.ekhui.Payment;
import com.sls.web.manager.game.querybean.DepositQuery;
import com.sls.web.manager.game.querybean.PaymentQuery;
import com.sls.web.manager.page.Pagination;
import com.sls.web.manager.pojo.UserInfoVO;

public class DepositAction  extends SuperAction{
	private Logger log = LoggerFactory.getLogger(DepositAction.class) ;
	private List<Deposit> depositList  ;
	private Pagination<Deposit> page;
	private Deposit deposit ;
	private DepositQuery depositQuery ;
	protected String startTime ;
	protected String endTime ;
	protected int recordCount ;
	public String list(){
		UserInfoVO userInfoVO = getCurrentOperator() ;
		DepositClient client = DepositClient.getInstance() ;
		if(deposit == null){
			deposit = new Deposit() ;
		}
		if (depositQuery == null) {
			depositQuery = new DepositQuery();
			depositQuery.setPageSize(Constants.INIT_PAGESIZE);
			depositQuery.setCurrentPage(Constants.INIT_CURRENTPAGE);
		}
		recordCount = client.getDepositCount(deposit, getStartTime(),
				getEndTime(),userInfoVO) ;
		if(page == null){
			page = new Pagination<Deposit>(depositQuery.getCurrentPage() , recordCount , depositQuery.getPageSize()) ;
		}
		depositList = client.getDepositList(deposit, getStartTime(),
				getEndTime() , depositQuery.getCurrentPage(), depositQuery.getPageSize() ,userInfoVO) ;
		
		page.setList(depositList) ;
		page.setRowCount(recordCount) ;
		return "list" ;
	}
	public String tocheckdeposit(){
		UserInfoVO userInfoVO = getCurrentOperator() ;
		DepositClient client = DepositClient.getInstance() ;
		deposit = client.getDeposit(deposit, userInfoVO) ;
		return "tocheckdeposit" ;
	}
	public String check(){
		UserInfoVO userInfoVO = getCurrentOperator() ;
		DepositClient client = DepositClient.getInstance() ;
		boolean res = client.checkDeposit(deposit, userInfoVO) ;
		message = String.valueOf(res) ;
		return "ajax" ;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	
	public String getStartTime() {
		if(StringUtils.isBlank(startTime)){
			startTime = DateUtil.getTodayBegin() ;
		}
		return startTime;
	}
	public void setStartTime(String startTime) {
		this.startTime = startTime ;
	}
	public String getEndTime() {
		if(StringUtils.isBlank(endTime)){
			endTime = DateUtil.getTodayEnd() ;
		}
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime ;
	}
	public List<Deposit> getDepositList() {
		return depositList;
	}
	public void setDepositList(List<Deposit> depositList) {
		this.depositList = depositList;
	}
	public Deposit getDeposit() {
		return deposit;
	}
	public void setDeposit(Deposit deposit) {
		this.deposit = deposit;
	}
	public Pagination<Deposit> getPage() {
		return page;
	}
	public void setPage(Pagination<Deposit> page) {
		this.page = page;
	}
	public DepositQuery getDepositQuery() {
		return depositQuery;
	}
	public void setDepositQuery(DepositQuery depositQuery) {
		this.depositQuery = depositQuery;
	}
}
